<div class="content-wrapper">
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>
        <h1 class="pull-right" id="dbshop-menu-top">
            <?php echo $this->HelpUrl('salesRanking'); ?>
        </h1>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <h2 class="page-header">
                            <?php echo $this->translate('销售排行'); ?>
                        </h2>
                        <div class="row">
                            <div class="col-xs-12">
                                <?php
                                $form = $this->form;
                                $form->prepare();
                                echo $this->form()->openTag($form);
                                ?>
                                <div class="col-xs-5 text-right">
                                    <a href="<?php echo $this->url('analysis', ['action' => 'salesRanking'], ['query' => ['userGroupId' => $form->get('userGroupId')->getValue()]]); ?>" class="btn <?php echo $this->type == 'today' ? 'btn-primary' : 'btn-default'; ?>"><?php echo $this->translate('今日'); ?></a>
                                    &nbsp;&nbsp;
                                    <a href="<?php echo $this->url('analysis', ['action' => 'salesRanking'], ['query' => ['type' => 'week', 'userGroupId' => $form->get('userGroupId')->getValue()]]); ?>" class="btn <?php echo $this->type == 'week' ? 'btn-primary' : 'btn-default'; ?>"><?php echo $this->translate('本周'); ?></a>
                                    &nbsp;&nbsp;
                                    <a href="<?php echo $this->url('analysis', ['action' => 'salesRanking'], ['query' => ['type' => 'month', 'userGroupId' => $form->get('userGroupId')->getValue()]]); ?>" class="btn <?php echo $this->type == 'month' ? 'btn-primary' : 'btn-default'; ?>"><?php echo $this->translate('本月'); ?></a>
                                </div>
                                <div class="col-xs-2">
                                    <?php echo $this->formElement($form->get('userGroupId')); ?>
                                </div>
                                <div class="col-xs-2">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-calendar" aria-hidden="true"></i></span>
                                        <?php echo $this->formElement($form->get('startDate')); ?>
                                    </div>
                                </div>
                                <div class="col-xs-2">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-calendar" aria-hidden="true"></i></span>
                                        <?php echo $this->formElement($form->get('endDate')); ?>
                                    </div>
                                </div>
                                <div class="col-xs-1">
                                    <button type="submit" class="btn btn-info"><?php echo $this->translate('查看'); ?></button>
                                </div>
                                <?php echo $this->form()->closeTag(); ?>
                            </div>
                        </div>
                    </div>

                    <div class="box-body table-responsive no-padding">
                        <table class="table shop-table table-hover">
                            <thead>
                            <tr class="shop-bg-thead">
                                <th width="5%"><?php echo $this->translate('排行'); ?></th>
                                <th width="30%"><?php echo $this->translate('商品名称'); ?></th>
                                <th width="15%"><?php echo $this->translate('商品货号'); ?></th>
                                <th width="20%"><?php echo $this->translate('商品规格'); ?></th>
                                <th width="10%"><?php echo $this->translate('商品销量'); ?></th>
                                <th width="10%"><?php echo $this->translate('商品销售额'); ?></th>
                                <th width="10%"><?php echo $this->translate('商品均价'); ?></th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            $basePageNum = $this->goodsRankingList->getItemCountPerPage() * ($this->goodsRankingList->getCurrentPageNumber()-1);
                            if ($this->goodsRankingList) foreach ($this->goodsRankingList as $rankingKey => $rankingValue) {?>
                                <tr>
                                    <td><?php echo $basePageNum + $rankingKey + 1; ?></td>
                                    <td><?php echo $this->escapeHtml($rankingValue[0]->getGoodsName()); ?></td>
                                    <td><?php echo $this->escapeHtml($rankingValue[0]->getGoodsItem()); ?></td>
                                    <td><?php echo $this->escapeHtml($rankingValue[0]->getInSpecGoodsStr()); ?></td>
                                    <td><?php echo $rankingValue['goodsNumTotal']; ?></td>
                                    <td><?php echo $rankingValue['goodsTotal']; ?></td>
                                    <td><?php echo number_format($rankingValue['goodsTotal']/$rankingValue['goodsNumTotal'], 2, '.', ''); ?></td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <?php echo $this->paginationControl($this->goodsRankingList, 'Sliding', 'layout/page', ['route' => 'analysis', 'params' => ['action' => 'salesRanking']]); ?>
                    </div>
                </div>
            </div>
        </div>

    </section>
</div>
<script>
    laydate.render({elem: '#startDate'});
    laydate.render({elem: '#endDate'});
</script>